package com.le.tester.leetcode;

/**
 * createTime：2022/6/16 17:01
 * description：是不是三的幂
 */
public class PowerOfThree {
    public static final double flag = 1.0;

    public boolean isPowerOfThree(int n) {
        if (n == 1) {
            return true;
        }
        double m = n;
        while (m > 1) {
            m = m / 3;
            if (m == flag) {
                return true;
            }
        }
        return false;
    }

    public static void main(String[] args) {
        System.out.println(new PowerOfThree().isPowerOfThree(1));
    }
}
